#!/bin/bash 
set -e


TMP=${TMP:-/tmp/work}
LOG=${LOG:-$HOME/logs/stage4}
SRC=${SRC:-/sources}

name=lvm2
version=2.03.11

rm -rf $TMP
mkdir -p $TMP $LOG

tar xf $SRC/$name-$version.tar.xz -C $TMP

{ time \
   {

    cd $TMP/$name-$version
    
	SAVEPATH=$PATH
	PATH=$PATH:/sbin:/usr/sbin
	./configure --prefix=/usr       \
	            --exec-prefix=      \
	            --enable-cmdlib     \
	            --enable-pkgconfig  \
	            --enable-udev_sync  \
	            --enable-dmeventd
	make
	PATH=$SAVEPATH
	unset SAVEPATH

	make install
	make install_systemd_units

    }
} 2>&1 | tee $name.log
    
[ $PIPESTATUS = 0 ] && mv $name.log $LOG || exit $PIPESTATUS

rm -fr $TMP
